package com.ryskoo.catering.ordermain.service;

import com.ryskoo.catering.ordermain.domain.OrderMainPO;
import com.ryskoo.common.dto.customer.VendorIndexInfo;
import com.ryskoo.framework.core.bean.QueryMessageDTO;
import com.ryskoo.framework.core.service.IBasicService;

import java.util.List;
import java.util.Map;

/**
 * @author BeHappy
 */
public interface IOrderMainService extends IBasicService<OrderMainPO> {

    /**
     * 根据订单编号获取订单
     *
     * @param orderId
     * @return
     */
    OrderMainPO getByOrderId(String orderId);

    /**
     * 获取订单系列数据（包含订单信息、订单明细、订单日志）
     * 通常在订单详情页可以调用此接口
     *
     * @return
     */
    OrderMainPO getFamily(String uuid, String invokeFrom);

    /**
     * 支付
     *
     * @param payResult
     */
    OrderMainPO pay(Map<String, Object> payResult);

    /**
     * 收款（商户收款）
     *
     * @param orderUuid
     * @param payMoney
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO gathering(String orderUuid, double payMoney, String operatorUuid, String operatorName);

    /**
     * 服务员代客下单
     *
     * @param po
     * @return
     */
    String saveForWaiter(OrderMainPO po);

    /**
     * 订单保存
     *
     * @param po
     * @return 订单uuid
     */
    String save(OrderMainPO po);

    /**
     * 商家取消订单
     *
     * @param orderUuid
     * @param refundMoney
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO cancelFromVendor(String orderUuid, double refundMoney, String operatorUuid, String operatorName);

    /**
     * 会员取消订单
     *
     * @param orderUuid
     */
    OrderMainPO cancelFromCustomer(String orderUuid);

    /**
     * 取消
     *
     * @param order
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO cancel(OrderMainPO order, String operatorUuid, String operatorName);

    /**
     * 退款成功回调
     *
     * @param orderUuid
     * @param refundStatus
     * @param successTime
     * @param callbackMsg
     */
    OrderMainPO refundCallback(String orderUuid, String refundStatus, String successTime, String callbackMsg);

    /**
     * 商家接单
     *
     * @param orderUuid
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO receive(String orderUuid, String operatorUuid, String operatorName);

    /**
     * 商家完成订单
     *
     * @param orderUuid
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO finish(String orderUuid, String operatorUuid, String operatorName);

    /**
     * 订单派送
     *
     * @param orderUuid
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO delivery(String orderUuid, String operatorUuid, String operatorName);

    /**
     * 订单已送达
     *
     * @param orderUuid
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO arrived(String orderUuid, String operatorUuid, String operatorName);

    /**
     * 订单修改价格
     *
     * @param orderUuid
     * @param price
     * @param operatorUuid
     * @param operatorName
     */
    OrderMainPO editPrice(String orderUuid, double price, String operatorUuid, String operatorName);

    /**
     * 根据商户查询当天的订单数量
     *
     * @param date       yyyy-MM-dd
     * @param vendorUuid
     * @return
     */
    int getOrderCountByDate(String date, String vendorUuid);

    /**
     * 根据商户查询当天的订单付款总金额
     *
     * @param date       yyyy-MM-dd
     * @param vendorUuid
     * @return
     */
    double getOrderAmtByDate(String date, String vendorUuid);


    /**
     * 查询商品月销数量
     *
     * @param products
     * @return
     */
    Map<String, Integer> getMonthSellNum(List<String> products);

    /**
     * 查询1个月内商户月销商品数量
     *
     * @param vendorUuid
     * @return
     */
    int getMonthSellProductNum(String vendorUuid);

    /**
     * 前台查询订单列表
     *
     * @param qm
     * @return
     */
    List<OrderMainPO> getList4FrontAndPage(QueryMessageDTO qm);

    void pushOrderNotification(String orderUuid);

    void pushToChief(String orderUuid);

    /**
     * 微信支付预下单
     *
     * @return
     */
    Map<String, Object> wxPreOrder(Map<String, Object> params);

    /**
     * 微信支付结果通知
     *
     * @param data 支付结果通知
     * @return 返回微信支付处理结果
     */
    Map<String, Object> payNotify(Map<String, String> data);

    /**
     * 微信退款结果通知
     *
     * @param data 退款结果通知
     * @return 返回微信退款处理结果
     */
    Map<String, Object> refundNotify(Map<String, String> data);

    /**
     * 订单加菜
     *
     * @param mainPO
     */
    void addDish(OrderMainPO mainPO);

    /**
     * 查询过去n天的商户每日统计信息
     * 收入、订单数、就餐人数
     *
     * @param vendorUuid 商户uuid
     * @param days       天数
     * @return
     */
    List<VendorIndexInfo> getDailyIndexInfoLastDays(String vendorUuid, int days);
}
